//
//  TSFindRecommendCell.m
//  TaShuo
//
//  Created by N-X on 2018/3/19.
//  Copyright © 2018年 MRNAN. All rights reserved.
//  猜你喜欢

#import "TSFindRecommendCell.h"
#import <UIButton+WebCache.h>

NSString * const kFindRecommendCellID = @"kFindRecommendCellID";

@interface TSFindRecommendCell()
@property (weak, nonatomic) IBOutlet UILabel *storeEnglishNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *storeNameLabel;
// 这些button 需要设置成custom类型，不然设置网络图片设置失败
@property (weak, nonatomic) IBOutlet UIButton *itemButton0;
@property (weak, nonatomic) IBOutlet UIButton *itemButton1;
@property (weak, nonatomic) IBOutlet UIButton *itemButton2;
@property (weak, nonatomic) IBOutlet UIImageView *headPicImageView;
@property (weak, nonatomic) IBOutlet UIImageView *iconImageView;
@end
@implementation TSFindRecommendCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
}

- (void)setFrame:(CGRect)frame
{
    frame.size.height -= 10;
    [super setFrame:frame];
}

#pragma mark - setter

- (void)setHeadPicUrl:(NSString *)headPicUrl
{
    [self.headPicImageView nx_setImageWithUrl:headPicUrl placeHolder:nil complete:^(UIImage * image) {
        self.headPicImageView.image = image;
    }];
}

- (void)setIconUrl:(NSString *)iconUrl
{
    [self.iconImageView nx_setImageWithUrl:iconUrl placeHolder:nil complete:^(UIImage *image) {
        self.iconImageView.image = image;
    }];
}

- (void)setStoreEnName:(NSString *)storeEnName
{
    self.storeEnglishNameLabel.text = storeEnName;
}

- (void)setStoreName:(NSString *)storeName
{
    self.storeNameLabel.text = storeName;
}

- (void)setItempicUrls:(NSArray *)itempicUrls
{
    [itempicUrls enumerateObjectsUsingBlock:^(NSString *  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        switch (idx) {
             case 0:
            {
                [self.itemButton0 sd_setImageWithURL:[NSURL URLWithString:obj] forState:UIControlStateNormal];
                //                [self button:self.itemButton0 setImageWithUrl:obj];
                break;
            }
             case 1:
            {
                 [self.itemButton1 sd_setImageWithURL:[NSURL URLWithString:obj] forState:UIControlStateNormal];
//                [self button:self.itemButton1 setImageWithUrl:obj];
                break;
            }
            case 2:
            {
                 [self.itemButton2 sd_setImageWithURL:[NSURL URLWithString:obj] forState:UIControlStateNormal];
//                [self button:self.itemButton2 setImageWithUrl:obj];
                break;
            }
        }
    }];
}

#pragma mark -  item点击事件

- (IBAction)itemClick:(UIButton *)sender {
    
}

#pragma mark - utils

- (void)button:(UIButton *)button setImageWithUrl:(NSString *)imageUrl
{
    [button.imageView nx_setImageWithUrl:imageUrl placeHolder:nil complete:^(UIImage *image) {
        [button setImage:image forState:UIControlStateNormal];
        [button setImage:image forState:UIControlStateHighlighted];
    }];
}
@end
